#include <stdio.h>
#include "cgic.h"
#include <string.h>
#include <stdlib.h>
#include <glib.h>


int cgiMain(){
    char serveripValue[128];
    char locationValue[256];
    
    cgiFormString("severIp",serveripValue,128);
    cgiFormString("location",locationValue,256);

    GKeyFile* keyfile = g_key_file_new();

    g_key_file_set_string(keyfile,"config","severIp",serveripValue);
    g_key_file_set_string(keyfile,"config","location",locationValue);


    g_key_file_save_to_file(keyfile,"../config/device.ini",NULL);

    g_key_file_free(keyfile);


    cgiHeaderContentType("text/html");
    fprintf(cgiOut, "<HTML><HEAD>\n");
	fprintf(cgiOut, "<TITLE>cgic test</TITLE></HEAD> <meta charset=\"UTF-8\">\n");
	fprintf(cgiOut, "<BODY><H1>配置成功！！</H1>\n");
    fprintf(cgiOut, "</BODY></HTML>\n");
    
    return 0;
}